package com.xy.liskov.improve;

/**
 * @author 谢阳
 * @version 1.8.0_131
 * @date 2022/6/7 20:16
 * @description
 */
public class Liskov {
    public static void main(String[] args) {
        A a = new A();
        System.out.println("11 - 3 = " + a.func1(11, 3));
        System.out.println("1 - 8 = " + a.func1(1, 8));
        System.out.println("---------------------");
        B b = new B();
        System.out.println("11 - 3 = " + b.func1(11, 3));
        System.out.println("1 - 8 = " + b.func1(1, 8));
        System.out.println("11 + 3 + 9 = " + b.func2(11, 3));

    }
}


/**
 * A 类
 */
class A {
    // 返回两个数的差
    public int func1(int num1, int num2) {
        return num1 - num2;
    }
}


/**
 * B类 继承A
 * 新增功能：完成两个数相加求和
 */
class B extends A {
    // 返回两个数的和
    public int func1(int num1, int num2) {
        return num1 + num2;
    }

    public int func2(int num1, int num2) {
        return func1(num1, num2) + 9;
    }

}